<template>
  <el-dialog :close-on-click-modal="false" title="修改" width="900px" :visible.sync="visible">
    <el-form :model="form" :label-position="labelPosition" label-width="100px">
      <el-row :gutter="24">
        <el-col>
          <el-form-item label="称谓">
            <el-input v-model="form.appellation" :style="inputWidth" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="姓名">
            <el-input v-model="form.name" :style="inputWidth" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="政治面貌">
            <el-input v-model="form.politicalStatus" :style="inputWidth" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="身份证号">
            <el-input v-model="form.idCards" :style="inputWidth" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="工作单位">
            <el-input v-model="form.workUnits" :style="inputWidth" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="手机号码">
            <el-input v-model="form.phone" :style="inputWidth" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button @click="handleUpdate" type="primary">修改</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { setSession, getSession } from '@/utils/util'
import { updateUserFamily } from '@/api/archives'
export default {
  data() {
    return {
      visible: false,
      form: {},
      labelPosition: 'right',
      inputWidth: {
        width: '80%'
      },
      userRow: this.$route.params.userRow
    }
  },
  methods: {
    handleUpdate() {
      this.$refs.form.validate(async valid => {
        if (valid) {
          const res = await updateUserFamily(this.form)
          if (res.state === '000000') {
            openNotification('success', '修改操作成功')
            this.visible = false
          }
        }
      })
    },
    edit(row) {
      console.log('row', row)
      this.visible = true
      this.form = Object.assign({}, row)
    }
  }
}
</script>
